<?php

namespace Member\Controller;

/**
 * 网站设置 控制器
 *
 * @since 1.0 <2015-10-20> SoChishun <14507247@qq.com> Added.
 * @since 1.1 2016-7-6 SoChishun SiteConfig 重构为 SiteConf
 * @since 1.2 2017-3-23 SiteConf重命名为Settings
 */
class Settings extends AppbaseController {

    // 2016-4-21
    public function edit() {
        $mSite = new \XWAM\Model\WebsiteConfModel();
        $data = $mSite->findSite(1, '');
        $this->assign('data', $data);
        $this->assign('tabs',$this->getTabs());
        $this->display();
    }
    // 2017-3-23
    public function seo() {
        $mSite = new \XWAM\Model\WebsiteConfModel();
        $data = $mSite->findSite(1, '');
        $this->assign('data', $data);
        $this->assign('tabs',$this->getTabs());
        $this->display();
    }
    // 2017-3-23
    public function lang() {
        $mSite = new \XWAM\Model\WebsiteConfModel();
        $data = $mSite->findSite(1, '');
        $this->assign('data', $data);
        $this->assign('tabs',$this->getTabs());
        $this->display();
    }
    // 2017-3-23
    public function db() {
        $mSite = new \XWAM\Model\WebsiteConfModel();
        $data = $mSite->findSite(1, '');
        $this->assign('data', $data);
        $this->assign('tabs',$this->getTabs());
        $this->display();
    }
    // 2017-3-23
    public function content() {
        $mSite = new \XWAM\Model\WebsiteConfModel();
        $data = $mSite->findSite(1, '');
        $this->assign('data', $data);
        $this->assign('tabs',$this->getTabs());
        $this->display();
    }
    // 2017-3-23
    public function admin() {
        $mSite = new \XWAM\Model\WebsiteConfModel();
        $data = $mSite->findSite(1, '');
        $this->assign('data', $data);
        $this->assign('tabs',$this->getTabs());
        $this->display();
    }

    public function editSave() {
        $mSite = new \XWAM\Model\WebsiteConfModel();
        $result = $mSite->saveSite();
        $this->dialogJump($result['status'], $result['info']);
    }
    // 2017-3-23
    protected function getTabs($name='') {
        if(!$name){
            $name=ACTION_NAME;
        }
        $data = array(
            'edit' => array( 'title' => '基本信息', 'url' => 'edit', 'active' => ''),
            'seo' => array( 'title' => 'SEO优化', 'url' => 'seo', 'active' => ''),
            'lang' => array( 'title' => '多语言设置', 'url' => 'lang', 'active' => ''),
            'db' => array( 'title' => '数据库设置', 'url' => 'db', 'active' => ''),
            'admin' => array('title' => '管理员设置', 'url' => 'admin', 'active' => ''),
            'content' => array( 'title' => '内容设置', 'url' => 'content', 'active' => ''),
        );
        if(array_key_exists($name, $data)){
            $data[$name]['active']='active';
        }
        return $data;
    }

}
